{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {},
   "outputs": [],
   "source": [
    "import tushare as ts\n",
    "from io import StringIO\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "\n",
    "def get_hist_numpy(code='600408', start='2017-01-01', end='2017-01-20'):\n",
    "    data = ts.get_hist_data(code, start=start, end=end)\n",
    "    data.to_csv('./123.csv')\n",
    "\n",
    "    df = pd.read_csv('./123.csv',header=None,sep=',') #filename可以直接从盘符开始，标明每一级的文件夹直到csv文件，header=None表示头部为空，sep=' '表示数据间使用空格作为分隔符，如果分隔符是逗号，只需换成 ‘，’即可。\n",
    "    df = df.loc[1:,1:]\n",
    "\n",
    "    data = np.array(df.T)\n",
    "    return (data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[['4.53' '4.7' '4.82' '4.83' '5.07' '5.05' '5.12' '5.2' '5.12' '5.03'\n",
      "  '5.25' '5.29' '5.28' '5.29']\n",
      " ['4.69' '4.7' '4.84' '4.89' '5.14' '5.2' '5.17' '5.23' '5.25' '5.22'\n",
      "  '5.28' '5.37' '5.36' '5.42']\n",
      " ['4.64' '4.53' '4.73' '4.84' '4.83' '5.14' '5.05' '5.14' '5.19' '5.12'\n",
      "  '5.22' '5.25' '5.29' '5.31']\n",
      " ['4.48' '4.44' '4.72' '4.69' '4.63' '5.01' '5.0' '5.11' '5.12' '5.03'\n",
      "  '5.14' '5.25' '5.23' '5.19']\n",
      " ['91829.27' '128508.56' '65355.0' '84825.33' '172523.67' '114809.28'\n",
      "  '73409.92' '73074.0' '102468.56' '130282.67' '109977.79' '83759.03'\n",
      "  '113568.96' '119403.67']\n",
      " ['0.11' '-0.2' '-0.11' '0.01' '-0.31' '0.09' '-0.09' '-0.05' '0.07'\n",
      "  '-0.1' '-0.03' '-0.04' '-0.02' '0.0']\n",
      " ['2.43' '-4.23' '-2.27' '0.21' '-6.03' '1.78' '-1.75' '-0.96' '1.37'\n",
      "  '-1.92' '-0.57' '-0.76' '-0.38' '0.0']\n",
      " ['4.714' '4.814' '4.918' '5.0' '5.07' '5.128' '5.144' '5.184' '5.214'\n",
      "  '5.238' '5.276' '5.274' '5.27' '5.228']\n",
      " ['4.921' '4.979' '5.051' '5.107' '5.154' '5.202' '5.209' '5.227' '5.221'\n",
      "  '5.205' '5.188' '5.173' '5.158' '5.137']\n",
      " ['5.055' '5.076' '5.105' '5.122' '5.142' '5.164' '5.169' '5.167' '5.163'\n",
      "  '5.164' '5.191' '5.207' '5.223' '5.236']\n",
      " ['108608.37' '113204.37' '102184.64' '103728.44' '107257.09' '98808.89'\n",
      "  '97842.59' '99912.41' '108011.4' '111398.42' '104628.32' '104537.21'\n",
      "  '129308.29' '133811.37']\n",
      " ['103708.63' '105523.48' '101048.53' '105869.92' '109327.76' '101718.6'\n",
      "  '101189.9' '114610.35' '120911.39' '119916.41' '118294.6' '115692.53'\n",
      "  '116856.87' '120991.72']\n",
      " ['111001.61' '110608.01' '108952.7' '113430.82' '113609.27' '110781.0'\n",
      "  '115231.66' '117901.95' '126747.9' '131486.55' '132740.62' '135281.63'\n",
      "  '137072.55' '138575.88']\n",
      " ['0.91' '1.28' '0.65' '0.84' '1.71' '1.14' '0.73' '0.73' '1.02' '1.29'\n",
      "  '1.09' '0.83' '1.13' '1.19']]\n"
     ]
    }
   ],
   "source": [
    "if __name__ == '__main__':\n",
    "    print(get_hist_numpy())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
